package view;

import controller.Controller;

@SuppressWarnings("serial")
public class TableModelYear extends TableModelDefault {

	private int year;

	/**
	 * Create the panel.
	 * 
	 * @param controller
	 * @param year
	 */
	public TableModelYear(Controller controller, int year) {
		super(controller);
		this.year = year;
	}

	@Override
	public int getRowCount() {
		return 13;
	}

	@Override
	public Object getValueAt(int monthRow, int column) {

		if (monthRow == 12) {
			if (column == 0) {
				return YEARSUMROW;
			} else if (column == columnNames.indexOf(INCOMECOLUMN)) {
				return controller.getModel().getYearIncomeSum(year, null);

			} else if (column == columnNames.indexOf(BALANCECOLUMN)) {
				return controller.getModel().getYearBalance(year, null, null);
			} else {
				return controller.getModel().getYearExpenseSum(year,
						getCategoryForModel(column), null);
			}
		}

		else {
			if (column == 0) {
				return controller.switchMonthTitle(monthRow);

			} else if (column == columnNames.indexOf(INCOMECOLUMN)) {
				return controller.getModel().getMonthIncomeSum(year, monthRow, null);
			} else if (column == columnNames.indexOf(BALANCECOLUMN)) {
				return controller.getModel().getMonthBalance(year, monthRow,
						null, null);
			} else {
				return controller.getModel().getMonthExpenseSum(year, monthRow,
						getCategoryForModel(column), null);
			}
		}
	}
}
